<html>
<head>
<meta charset="UTF-8">
<title>批次信息配置详情</title>
	<link  id="easyuiTheme" href="../../static/easyui/themes/bootstrap/easyui.css" rel="stylesheet" type="text/css"/>
	<link href="../../static/easyui/themes/icon.css" rel="stylesheet" type="text/css"/>
	<link href="../../static/css/esaas-easyui-view.css" rel="stylesheet" type="text/css"/>
	<script src="../../static/easyui/jquery.min.js" type="text/javascript"></script>
	<script src="../../static/easyui/jquery.cookie.js" type="text/javascript"></script>
	<script src="../../static/easyui/ui-theme.js" type="text/javascript"></script>
	<script src="../../static/easyui/jquery.easyui.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="../../static/easyui/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>
	<script src="../../static/plugin/assets/jslib.util.js" type="text/javascript"></script>
	<script src="../../static/plugin/assets/jslib.jquery.ajax.js" type="text/javascript"></script>
	<script src="../../static/plugin/assets/jslib.easyui.util.js" type="text/javascript"></script>
	<script src="../../ffres/dict/all.js" type="text/javascript"></script>
	<a href="" target="_blank" id="commonLink" name="commonLink"></a>
</head>
<body class="easyui-layout">

	    <form id="ff" method="post">
	    	<div class="esaas-info-title">批次信息配置信息</div>
	    	<table class="esaas-info-view-table">
			<tr>
				<td width="15%" align="right">批次标识：</td>
				<td width="35%"><input class="easyui-textbox" type="text"
					name="batchId" data-options="required:true, disabled: true, disabled: true"
					style="width: 100%; height: 25px;"></input></td>
				<td width="15%" align="right">批次名称：</td>
				<td width="35%"><input class="easyui-textbox" type="text"
					name="batchName" data-options="required:true, disabled: true"
					style="width: 100%; height: 25px;"></input></td>
			</tr>
			<tr>
				<td width="15%" align="right">系统代码：</td>
				<td width="35%"><input class="easyui-textbox" type="text"
					name="subsCode" data-options="required:true, disabled: true, disabled: true"
					style="width: 100%; height: 25px;"></input></td>
				<td width="15%" align="right">发起方式：</td>
				<td width="35%"><select class="easyui-combobox"
					id="launchType" name="launchType"
					style="width: 100%; height: 25px;"
					data-options="required:false, disabled: true,editable:false,valueField:'enname',textField:'cnname',data:BAT_LAUNCH_TYPE">
				</select></td>
			</tr>
			<tr>
				<td width="15%" align="right">执行周期：</td>
				<td width="35%"><input class="easyui-textbox"
									   id="batchCronValue" name="batchCronValue" data-options="required:true"
									   style="width: 100%; height: 25px;"></input>
					<select class="easyui-combobox" type="text" id="select_cron" style="width: 20%; height: 25px;"
							data-options="required:false,editable:false,disabled: true,valueField:'value',textField:'text',onSelect:selectCron">
						<option value="day">每天</option>
						<option value="nDay">N天</option>
						<option value="hours">每小时</option>
						<option value="nHours">N小时</option>
						<option value="nMinutes">N分钟</option>
						<option value="week">每星期</option>
						<option value="month">每月</option>
					</select>
					<select class="easyui-combobox" id="week" style="width: 20%; height: 25px;"
							data-options="required:false,editable:false,disabled: true,valueField:'value',textField:'text'">
						<option value="1">周一</option>
						<option value="2">周二</option>
						<option value="3">周三</option>
						<option value="4">周四</option>
						<option value="5">周五</option>
						<option value="6">周六</option>
						<option value="7">周日</option>
					</select>
					<select class="easyui-combobox" id="day" style="width: 25%; height: 25px;" buttonText="天"
							data-options="required:false,editable:true,disabled: true,valueField:'value',textField:'text'">
					</select>
					<select class="easyui-combobox" id="hours" style="width: 25%; height: 25px;" buttonText="时"
							data-options="required:false,editable:true,disabled: true,valueField:'value',textField:'text'">
					</select>
					<select class="easyui-combobox" id="minutes" style="width: 25%; height: 25px;" buttonText="分"
							data-options="required:false,editable:true,disabled: true,valueField:'value',textField:'text'">
					</select>
				</td>
				<td width="15%" align="right">执行节点标识：</td>
				<td width="35%"><input class="easyui-textbox" type="text"
					name="agentId" data-options="required:true, disabled: true"
					style="width: 100%; height: 25px;"></input></td>
			</tr>
			<tr>
				<td width="15%" align="right">生效日期：</td>
				<td width="35%"><input class="easyui-datebox" type="text"
					name="validDate" data-options="required:false, disabled: true"
					style="width: 100%; height: 25px;"></input></td>
				<td width="15%" align="right">任务并发数：</td>
				<td width="35%"><input class="easyui-textbox" type="text"
					name="equallyTaskAmount" data-options="required:true, disabled: true"
					style="width: 100%; height: 25px;"></input></td>
			</tr>
			<tr>
				<td width="15%" align="right">是否允许重跑：</td>
				<td width="35%"><select class="easyui-combobox"
					id="isRunAgain" name="isRunAgain"
					style="width: 100%; height: 25px;"
					data-options="required:false, disabled: true,editable:false,valueField:'enname',textField:'cnname',data:STD_PUB_YN">
				</select></td>
			</tr>
			<tr>
				<td width="15%" align="right">备注：</td>
				<td width="85%" colspan="3"><input class="easyui-textbox" type="text"
					name="remark" data-options="required:false, disabled: true, multiline: true"
					style="width: 100%; height: 50px;"></input></td>
			</tr>
	    	</table>
	    </form>
	    <div class="esaas-info-buttons">
			<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="closeForm()" style="width:90px">&nbsp;关&nbsp;闭&nbsp;</a>
		</div>
	</div>
	<script>	
		$(function() {
		    addTitle("查看")
			var batchId = $.getUrlParam('batchId');
			cronShowInit();
			$.restfulGet('../../api/bat/batch/info/config/' + batchId,null,function(data){
					$('#ff').form('load', {
						batchId : data.rows.batchId,
						batchName : data.rows.batchName,
						subsCode : data.rows.subsCode,
						launchType : data.rows.launchType,
						batchCronValue : data.rows.batchCronValue,
						validDate : data.rows.validDate,
						equallyTaskAmount : data.rows.equallyTaskAmount,
						isRunAgain : data.rows.isRunAgain,
						agentId : data.rows.agentId,
						remark : data.rows.remark
					});
				showByCron(data.rows.batchCronValue);
			});
		});

		function showByCron(cron){
			if(cron != null && cron !=""){
				var cronList=cron.trim().split(" ");
				if(cronList[5]=="?"){
					if(cronList[2]=="*"&&cronList[3]=="*"&&cronList[4]=="*"){
						if(cronList[1].indexOf("*/")==-1){
							$("#minutes").combobox("setValue",cronList[1]);
							$("#select_cron").combobox("setValue","hours")
						}else{
							cronList[1]=cronList[1].replace("*/","");
							$("#minutes").combobox("setValue",cronList[1]);
							$("#select_cron").combobox("setValue","nMinutes")
						}
					}else if(cronList[3]=="*"&&cronList[4]=="*"){
						if(cronList[2].indexOf("*/")==-1){
							$("#hours").combobox("setValue",cronList[2]);
							$("#minutes").combobox("setValue",cronList[1]);
							$("#select_cron").combobox("setValue","day")
						}else{
							cronList[2]=cronList[2].replace("*/","");
							$("#hours").combobox("setValue",cronList[2]);
							$("#minutes").combobox("setValue",cronList[1]);
							$("#select_cron").combobox("setValue","nHours")
						}
					}else if(cronList[4]=="*"){
						if(cronList[3].indexOf("*/")==-1){
							$("#day").combobox("setValue",cronList[3]);
							$("#hours").combobox("setValue",cronList[2]);
							$("#minutes").combobox("setValue",cronList[1]);
							$("#select_cron").combobox("setValue","month")
						}else{
							cronList[3]=cronList[3].replace("*/","");
							$("#day").combobox("setValue",cronList[3]);
							$("#hours").combobox("setValue",cronList[2]);
							$("#minutes").combobox("setValue",cronList[1]);
							$("#select_cron").combobox("setValue","nDay")
						}
					}
				}else{
					$("#week").combobox("setValue",cronList[5]);
					$("#hours").combobox("setValue",cronList[2]);
					$("#minutes").combobox("setValue",cronList[1]);
					$("#select_cron").combobox("setValue","week")
				}
			}
			selectCron();
		}

		function cronShowInit(){
			$("#batchCronValue").next().hide();
			var hoursData = [{}];
			for (var i = 0; i < 24; i++) {
				hoursData.push({ text: i, value: i });
			}
			$("#hours").combobox("loadData", hoursData);
			var minutesData = [{}];
			for (var i = 0; i < 60; i++) {
				minutesData.push({ text: i, value: i });
			}
			$("#minutes").combobox("loadData", minutesData);
			var dayData = [{}];
			for (var i = 1; i < 32; i++) {
				dayData.push({ text: i, value: i });
			}
			$("#day").combobox("loadData", dayData);
			$("#week").next().hide();
			$("#day").next().hide();
		}

		function selectCron(){
			var selectValue=$("#select_cron").combobox("getValue");
			if(selectValue=="day" ||selectValue=="nHours"){
				$("#week").next().hide();
				$("#day").next().hide();
				$("#hours").next().show();
				$("#minutes").next().show();
			}else if(selectValue=="month"||selectValue=="nDay"){
				$("#week").next().hide();
				$("#day").next().show();
				$("#hours").next().show();
				$("#minutes").next().show();
			}else if(selectValue=="hours"||selectValue=="nMinutes"){
				$("#week").next().hide();
				$("#day").next().hide();
				$("#hours").next().hide();
				$("#minutes").next().show();
			}else if(selectValue=="week"){
				$("#week").next().show();
				$("#day").next().hide();
				$("#hours").next().show();
				$("#minutes").next().show();
			}
		}

		function closeForm(){
			window.parent.JLEUtil.closewin();
		}
	</script>
</body>
</html>